<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css" />
    <link rel="stylesheet" type="text/css" href="css/good-list.css"/>

</head>
<body>
<!-- 顶部 -->

<jsp:include page="header.jsp"></jsp:include>

<!--products-->
<div class="products">
    <div class="container">
        <h2>热销商品</h2>

        <div class="product-model-sec">

            <c:forEach items="${requestScope.pageBean.goodsList}" var="goods">
                <div class="product-grid">
                    <a href="/goods_detail?id=9">
                        <div class="more-product"><span> </span></div>
                        <div class="product-img">
                            <img src="${pageContext.request.contextPath}/${goods.image1}" class="img-responsive" alt="${goods.name}" width="240" height="240">

                        </div>
                    </a>
                    <div class="product-info ">
                        <div class="product-info-cust">
                            <h4>${goods.name}</h4>
                            <span class="item_price">¥ ${goods.price}</span>
                            <a href="${pageContext.request.contextPath}/addGoodsToCartServlet?id=${goods.id}" class="item_add items">加入购物车</a>
                        </div>
                    </div>
                </div>

            </c:forEach>






        </div>
        <!--bootstrap的分页组件-->
        <div style="margin: 0 auto;width: 500px">
            <nav aria-label="Page navigation" >
                <ul class="pagination">
                    <!--标签li中class的值的含义
                    disabled : 禁用
                    active ：激活
                    -->
                    <c:if test="${requestScope.pageBean.currentPage==1}">
                        <li class="disabled" >
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">上一页</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${requestScope.pageBean.currentPage!=1}">
                        <li >
                            <a href="${pageContext.request.contextPath}/goodsListPageServlet?currentPage=${requestScope.pageBean.currentPage-1}" aria-label="Previous">
                                <span aria-hidden="true">上一页</span>
                            </a>
                        </li>
                    </c:if>

                    <c:forEach begin="${(requestScope.pageBean.currentPage-4)>0?(requestScope.pageBean.currentPage-4):1}" end="${(requestScope.pageBean.currentPage+3)>requestScope.pageBean.totalPage?requestScope.pageBean.currentPage:(requestScope.pageBean.currentPage+3)}" var="pageNum">
                        <c:if test="${requestScope.pageBean.currentPage==pageNum}">
                            <li class="active"><a href="${pageContext.request.contextPath}/goodsListPageServlet?currentPage=${pageNum}">${pageNum}</a></li>
                        </c:if>
                        <c:if test="${requestScope.pageBean.currentPage!=pageNum}">
                            <li><a href="${pageContext.request.contextPath}/goodsListPageServlet?currentPage=${pageNum}">${pageNum}</a></li>
                        </c:if>
                    </c:forEach>



                    <c:if test="${requestScope.pageBean.currentPage==requestScope.pageBean.totalPage || requestScope.pageBean.totalPage==0}">
                        <li class="disabled">
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">下一页</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${requestScope.pageBean.currentPage!=requestScope.pageBean.totalPage && requestScope.pageBean.totalPage!=0}">
                        <li >
                            <a href="${pageContext.request.contextPath}/goodsListPageServlet?currentPage=${requestScope.pageBean.currentPage+1}" aria-label="Previous">
                                <span aria-hidden="true">下一页</span>
                            </a>
                        </li>
                    </c:if>
                </ul>
            </nav>

        </div>
    </div>
</div>
</body>
</html>
